const url = require('url');

const api = 'http://www.i.com?name=zhangsan&age=20';

console.log(url.parse(api, true));

const temp = url.parse(api, true).query;

console.log(temp);
console.log(temp.name);
console.log(temp.age);